FROM openjdk:8

MAINTAINER zn

ARG APP_NAME
ARG APP_VERSION
ARG EXPOSE_PORT
ARG PROFILES_ACTIVE
ARG EUREKA_DEFAULT_ZONE=$EUREKA_DEFAULT_ZONE

ENV APP_NAME $APP_NAME
ENV APP_JAR_VERSION $APP_NAME-$APP_VERSION.jar
ENV APP_VERSION $APP_VERSION
ENV EXPOSE_PORT ${EXPOSE_PORT:-5000}
ENV PROFILES_ACTIVE ${PROFILES_ACTIVE:-dev}
ENV EUREKA_DEFAULT_ZONE $EUREKA_DEFAULT_ZONE

WORKDIR /usr/src/app

COPY  target/$APP_JAR_VERSION /usr/src/app

EXPOSE $EXPOSE_PORT

RUN echo APP_NAME:$APP_JAR_VERSION
RUN echo EXPOSE_PORT:$EXPOSE_PORT
RUN echo PROFILES_ACTIVE:$PROFILES_ACTIVE

RUN echo "java -jar $APP_JAR_VERSION --server.port=$EXPOSE_PORT --spring.profiles.active=$PROFILES_ACTIVE "

CMD [ "sh", "-c", "java -jar $APP_JAR_VERSION --server.port=$EXPOSE_PORT --spring.profiles.active=$PROFILES_ACTIVE "]
